<template>  
    <div class="wrapper">
        <minibar title="首页" :isPadding="true">
            <div slot="middle" class="x-suosou" @click="openSearch">
                <text class="x-sousuo-icon iconfont">&#xe677;</text>
                <text class="x-sousuo-text">搜索商品</text>
            </div>
        </minibar>
        <list show-scrollbar="false" class="x-list">
            <refresh class="refresh" @refresh="onrefresh" :display="refreshing ? 'show' : 'hide'">
                <loading-indicator class="indicator"></loading-indicator>
            </refresh>
            <cell>
                <x-slider :imageList="banners"></x-slider>
                <x-palace></x-palace>
                <div class="x-goshop-div">
                    <image class="x-goshop" :src="goshopimg" @click="goShop"></image>
                    <div class="x-go-info">
                        <text class="x-go-text">{{store_name||"无"}}</text>
                        <text class="x-go-text2">地址：{{store_address||"无"}}</text>
                        <text class="x-go-text2">电话：{{store_phone||"无"}}</text>
                    </div>
                </div>
                <image class="x-shopbottom" :src="shopbottom"></image>
                <x-special :listData="xpData"></x-special>
                <x-imagelist :listData="soData"></x-imagelist>
                 
            </cell>
        </list>
    </div>
</template>

<script>
    import asCore from "../../common/js/core";
    const modal = weex.requireModule('modal');
    const navigator = weex.requireModule('navigator');
    export default {
        components: { 
            "minibar" :require("../../common/component/minbar.vue"),
            "x-slider" :require("./comp/slider.vue"),
            "x-palace" :require("./comp/palace.vue"),
            "x-imagelist":require("./comp/imagelist.vue"),
            "x-special":require("../index/comp/special.vue"),
        },
        data () {
            return {
                storeid:null,
                store_name:"-",
                store_address:"-",
                store_phone:"-",
                refreshing: false,
                banners: [
                    {src: asCore.localpath + "img/store.gif"}
                ],
                topic:"-",
                soData :{
                    topimage:asCore.localpath + "img/home/tejia.png",
                    data:[]
                },
                xpData :{
                    topimage:asCore.localpath + "img/xptj.png",
                    data:[]
                },
                goshopimg:asCore.localpath + "img/store_dd.png",
                shopbottom:asCore.localpath + "img/store_top.png",
                recdimg:asCore.localpath + "img/xptj.png"
            }
        },
        methods: {
            set_storedata(data){
                this.storeid = data['id'];
                this.store_name = data['name'];
                this.store_address = data['address'];
                this.store_phone = "15896678888";
            },
            /*加载首页数据 */
            loadMainData(callback){
                //asCore.toast(this.storeid);
                asCore.post("/store/home",{store_id:this.storeid},(data,msg,flag)=>{
                    if(flag==true){
                       //asCore.toast(this.storeid);
                       this.loadGoods_new(data);
                    }
                    callback && callback();
                });
            },
            /*加载推荐数据 */
            loadGoods_new(data){
                /*加载特价推荐内容 */
                this.soData.data = data['goods_hot'];
                this.xpData.data = data['goods_new'];
                
            },
            onrefresh (event) {
                var _this = this;
                _this.refreshing = true;
                _this.loadMainData(()=>{
                    _this.refreshing = false;
                    modal.toast({
                        message:"刷新成功"
                    });
                });
            },
            goShop(){
                navigator.push(asCore.localpath + 'tailor/index/store.js');
            },
            isIos () {
                const { platform } = weex.config.env;
                return platform.toLowerCase() === 'ios';
            }
        }
    };
</script>
<style scoped src="./css/home.css">
</style>
